﻿using StackExchange.Redis.KeyspaceIsolation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace daonaite.core.Catche
{
    /// <summary>
    /// 缓存操作方法
    /// </summary>
    public interface ICacheHelp
    {
        /// <summary>
        /// 设置缓存值,永不过期
        /// </summary>
        /// <typeparam name="T">数据类型</typeparam>
        /// <param name="key">key</param>
        /// <param name="data">数据</param>
        /// <param name="databse">数据块</param>
        void set<T>(string key, T data, int databse = 0);

        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <typeparam name="T">数据类型</typeparam>
        /// <param name="key">key</param>
        /// <param name="data">数据</param>
        /// <param name="ExpirationTime">过期时间,秒</param>
        /// <param name="databse">数据块</param>
        public void set<T>(string key, T data, int ExpirationTime, int databse = 0);

        /// <summary>
        /// 获取缓存值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        /// <param name="databse">数据块</param>
        public T? get<T>(string key, int databse = 0);

        /// <summary>
        /// 删除key
        /// </summary>
        /// <param name="key"></param>
        /// <param name="databse">数据块</param>
        public void remove(string key, int databse = 0);


        /// <summary>
        /// 左侧入
        /// </summary>
        /// <typeparam name="T">数据类型</typeparam>
        /// <param name="key">key</param>
        /// <param name="data">数据</param>
        /// <param name="databse">数据块</param>
        public void listleftPush<T>(string key, T data, int databse = 0);

        /// <summary>
        /// 右侧入
        /// </summary>
        /// <typeparam name="T">数据类型</typeparam>
        /// <param name="key">key</param>
        /// <param name="data">数据</param>
        /// <param name="databse">数据块</param>
        public void listrightPush<T>(string key, T data, int databse = 0);

        /// <summary>
        /// 左侧出
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        /// <param name="databse">数据块</param>
        public T? listleftPop<T>(string key, int databse = 0);

        /// <summary>
        /// 右侧出
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        /// <param name="databse">数据块</param>
        public T? listrightPop<T>(string key, int databse = 0);

        /// <summary>
        /// 查询list 数量
        /// </summary>
        /// <param name="key">key</param>
        /// <returns>剩余数量</returns>
        /// <param name="databse">数据块</param>
        public int listcount(string key, int databse = 0);
    }
}
